{include file="public/header" /}
<body>
<style>
    .cion{
        display: inline-block;
        width: 120px;
    }
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 系统管理
    <span class="c-gray en">&gt;</span> 基本配置
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="/system/config" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form  method="get" action="">
        <div class="text-c">
            <input type="text" class="input-text" style="width:250px" placeholder="key|描述模糊查找" value="{:input('word')}" name="word">
            <span class="select-box" style="width: 100px;">
                <select name="status" class="select">

                    <option value="">全部分类</option>
                     {foreach $types as $v}
                        <option value="{$v.code}" {if isset($v['code']) && $v['code'] == $type }selected{/if}>{$v.name}</option>
                    {/foreach}
                </select>
            </span>
            <button type="submit" class="btn btn-success">搜索</button>
        </div>
    </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
          <span class="l">
            <a href="javascript:;" onclick="layopen('新增配置','{:url('config_edit')}')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>新增配置</a>
              <a href="javascript:;" onclick="feed_config()" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>同步配置到redis</a>
        </span>
        <span class="r">共有数据：<strong>{$list->total()}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-hover table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="9">配置列表</th>
        </tr>
        <tr class="text-c">
            <th width="70">分类编码</th>
            <th width="100">配置key</th>
            <th width="80">配置value</th>
            <th width="80">配置说明</th>
            <th width="80">是否同步</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $v}
        <tr class="text-c">
            <td>{$v.type}</td>
            <td>{$v.key}</td>
            <td>{$v.name}</td>
            <td>{$v.desc}</td>
            <td> {if $v.sy == 1}
                    同步
                {else /} 未同步
                {/if}</td>
            <td>
                <a class="btn btn-default radius" title="配置详情" href="javascript:;" onclick="layopen('配置详情','{:url('config_edit',['id'=>$v.id])}')"><i class="Hui-iconfont">&#xe6df;</i></a>
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    <div class="page">
        {$list->render()|raw}
    </div>
</div>

{include file="public/footer" /}
<script type="text/javascript">
    function feed_config(){
        var info = '确认要同步吗？';
        layer.confirm(info,function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('feed_config_redis')}",
                dataType: 'json',
                success: function(data){
                    window.location.href="/system/config";
                    if(data.status == 'y'){
                        layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){

                        });
                    }else{
                        layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }


</script>
